# 实现化接口
class DrawingAPI:
    def draw_circle(self, x, y, radius):
        pass


# 具体实现化1
class DrawingAPI1(DrawingAPI):
    def draw_circle(self, x, y, radius):
        print(f"API1.circle at {x}:{y} radius {radius}")


# 具体实现化2
class DrawingAPI2(DrawingAPI):
    def draw_circle(self, x, y, radius):
        print(f"API2.circle at {x}:{y} radius {radius}")


# 抽象化
class Shape:
    def __init__(self, drawing_api):
        self.drawing_api = drawing_api

    def draw(self):
        pass

    def resize_by_percentage(self, pct):
        pass


# 细化抽象化
class CircleShape(Shape):
    def __init__(self, x, y, radius, drawing_api):
        super().__init__(drawing_api)
        self.radius = radius
        self.x = x
        self.y = y

    def draw(self):
        self.drawing_api.draw_circle(self.x, self.y, self.radius)

    def resize_by_percentage(self, pct):
        self.radius *= pct


# 客户端代码
circle1 = CircleShape(1, 2, 3, DrawingAPI1())
circle2 = CircleShape(5, 7, 11, DrawingAPI2())

circle1.draw()
circle2.draw()

circle1.resize_by_percentage(5)
circle2.resize_by_percentage(5)

circle1.draw()
circle2.draw()

'''
API1.circle at 1:2 radius 3
API2.circle at 5:7 radius 11
API1.circle at 1:2 radius 15
API2.circle at 5:7 radius 55
'''